<?php
/**
 * Created by PhpStorm.
 * User: JackWang
 * Date: 2022/5/6
 * Time: 11:32
 */
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http\Request;
require_once 'vendor/autoload.php';

//创建一个worker监听2345端口，使用http协议
$http_worker = new Worker('http://127.0.0.2:2345');

//启动四个进程对外提供服务
$http_worker->count = 4;

//接收到浏览器发送的数据是回复hello world给浏览器
$http_worker->onMessage = function (TcpConnection $connection,Request $request)
{
    //向浏览器发送hello world
    $connection->send('hello world');
};

//运行worker
Worker::runAll();